using System.Collections;
using System.Collections.Generic;
using Common.Pool;
using UnityEngine;
namespace MiniAnimation
{
    public partial class MiniAnimate
    {
        public delegate T Getter<out T>();
        public delegate void Setter<in T>(T pNewValue);
        public delegate T Lerp<T>(T CurrentValue, T NewValue, float BlendFactor);
        #region  minoTo
        public static MiniAnim MiniTo(Getter<float> getter, Setter<float> setter, float targetValue,
        float duration, MiniCurve curve = MiniCurve.None)
        {
            MiniAnim currentAnim = GetMiniAnim();
            (currentAnim as IMiniAnim).DoMiniTo(getter, setter, Lerp.FloatLerp, targetValue, duration, curve);
            return currentAnim;
        }
        public static MiniAnim MiniTo(Getter<Vector3> getter, Setter<Vector3> setter, Vector3 targetValue,
        float duration, MiniCurve curve = MiniCurve.None)
        {
            MiniAnim currentAnim = GetMiniAnim();
            (currentAnim as IMiniAnim).DoMiniTo(getter, setter, Lerp.Vector3Lerp, targetValue, duration, curve);
            return currentAnim;
        }
        public static MiniAnim MiniTo(Getter<Vector2> getter, Setter<Vector2> setter, Vector2 targetValue,
      float duration, MiniCurve curve = MiniCurve.None)
        {
            MiniAnim currentAnim = GetMiniAnim();
            (currentAnim as IMiniAnim).DoMiniTo(getter, setter, Lerp.Vector2Lerp, targetValue, duration, curve);
            return currentAnim;
        }
        public static MiniAnim MiniTo(Getter<Quaternion> getter, Setter<Quaternion> setter, Quaternion targetValue,
        float duration, MiniCurve curve = MiniCurve.None)
        {
            MiniAnim currentAnim = GetMiniAnim();
            (currentAnim as IMiniAnim).DoMiniTo(getter, setter, Lerp.QuaternionLerp, targetValue, duration, curve);
            return currentAnim;
        }
        public static MiniAnim MiniTo(Getter<Color> getter, Setter<Color> setter, Color targetValue,
        float duration, MiniCurve curve = MiniCurve.None)
        {
            MiniAnim currentAnim = GetMiniAnim();
            (currentAnim as IMiniAnim).DoMiniTo(getter, setter, Lerp.ColorLerp, targetValue, duration, curve);
            return currentAnim;
        }
        public static MiniAnim MiniTo(Getter<double> getter, Setter<double> setter, double targetValue,
        float duration, MiniCurve curve = MiniCurve.None)
        {
            MiniAnim currentAnim = GetMiniAnim();
            (currentAnim as IMiniAnim).DoMiniTo(getter, setter, (a, b, c) => (float)Lerp.FloatLerp((float)a, (float)b, c), targetValue, duration, curve);
            return currentAnim;
        }
        #endregion
        //生成的唯一入口
        static MiniAnim GetMiniAnim()
        {
            var obj =  new MiniAnim() { };
            obj.isUsed = true;
            return obj;
        }
    }
}